#include"proc.h"
#include<time.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
typedef void (*flush)(double total,double cur); //刷新的函数指针类型

double total = 2048.0;
const int  base = 100.0;
double once = 0.5;

void Download(flush f)
{
    double cur = 0.0; //从0开始下载
    while(cur < total)
    {
        //模拟下载行为
        int r = rand() % base + 1;
        double speed = once * r;
        cur += speed;
        if(cur > total)
            cur = total;
        f(total,cur);
        usleep(50000);
    }
    printf("\n");
}

int main()
{
    srand(time(NULL));
   //proc();
   Download(FlushProcess);
   Download(FlushProcess);
   Download(FlushProcess);
   Download(FlushProcess);
   Download(FlushProcess);
    return 0;
}
